<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
            "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>



<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="hevea 1.08">
<LINK rel="stylesheet" type="text/css" href="libman.css">
<TITLE>
Using the constraints
</TITLE>
</HEAD>
<BODY >
<A HREF="libman013.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="libman011.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="libman015.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<HR>

<H2 CLASS="section"><A NAME="htoc23">2.3</A>&nbsp;&nbsp;Using the constraints</H2>
To use the constraints, ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> needs to know which solver to pass a
particular constraint to. The easiest method for doing this is to module
qualify the constraint. For example,
<PRE CLASS="verbatim">
    ..., ic: (A #&gt;= B), ...
</PRE>
passes the constraint <CODE>A #&gt;= B</CODE> to the ic solver. The solver must be
loaded first (e.g. via lib/1) before any constraint can be passed to it.<BR>
<BR>
A constraint can also be passed to more than one solver by specifying a
list in the module qualification. For example,
<PRE CLASS="verbatim">
    ..., [ic, suspend]: (A #&gt;= B), ...
</PRE>
will pass the constraint to both the ic and suspend solvers. <BR>
<BR>
Module qualification is <EM>not</EM> needed if the constraint is defined by an
imported module, and there is no other imported module
which defines the same constraint. For example, if ic is the only imported
module which defines <CODE>#&gt;=/2</CODE>, then <CODE>#&gt;=/2</CODE> can be used without 
qualification:
<PRE CLASS="verbatim">
    ..., A #&gt;= B, ...
</PRE>
Note that for constraints that are defined for <CODE>eclipse_language</CODE>,
such as <CODE>&gt;=</CODE> (the standard arithmetic test), the default behaviour
when an unqualified call to such a
constraint is made is to pass it to <CODE>eclipse_language</CODE>,
even if another solver which defines the constraint is imported.
Thus, for example
<PRE CLASS="verbatim">
    ..., A &gt;= B, ...
</PRE>
will by default have standard (i.e. non-suspending) test semantics, even
if, e.g. the <CODE>ic</CODE> library (which also defines <CODE>&gt;=/2</CODE>) is
imported. To access the <CODE>ic</CODE> version, module qualification should
be added:
<PRE CLASS="verbatim">
    ..., ic:(A &gt;= B), ...
</PRE>Alternatively, the synonymous <CODE>$&gt;=/2</CODE> constraint could be used:
<PRE CLASS="verbatim">
    ..., A $&gt;= B, ...
</PRE>
In general, module qualifications are recommended if the programmer
wants to ensure a particular constraint behaviour regardless of which
other modules might be loaded. On the other hand, if the intention is
to switch easily between different solvers by simply loading a
different library, module qualification is best omitted.<BR>
<BR>
Finally, it is also possible to let the running program determine which
solver to use. In this case, the program has a variable in the module
position, which will only be bound at runtime:
<PRE CLASS="verbatim">
    ..., Solver:(A #&gt;= B), ...
</PRE>This will however prevent the solver from performing any compile-time
preprocessing on the constraint.<BR>
<BR>
<HR>
<A HREF="libman013.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="libman011.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="libman015.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>
